package com.ldl.handle.spring.framework.beans.support;

import com.ldl.handle.spring.framework.beans.config.LdlBeanDefinition;
import com.ldl.handle.spring.framework.core.LdlBeanFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ldl  想过夏天的雪人
 * @Date 2022-10-13 11:23
 */
public class LdlDefaultListableBeanFactory implements LdlBeanFactory {

    public Map<String, LdlBeanDefinition> beanDefinitionMap = new HashMap<String, LdlBeanDefinition>();

    @Override
    public Object getBean(Class beanClass) {
        return null;
    }

    @Override
    public Object getBean(String beanName) {
        return null;
    }

    public void doRegistBeanDefinition(List<LdlBeanDefinition> beanDefinitions) throws Exception {
        for (LdlBeanDefinition beanDefinition : beanDefinitions) {
            if (this.beanDefinitionMap.containsKey(beanDefinition.getFactoryBeanName())) {
                throw new Exception(beanDefinition.getFactoryBeanName() + "已存在！！！");
            }
            this.beanDefinitionMap.put(beanDefinition.getFactoryBeanName(), beanDefinition);
        }
    }
}
